<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>兼职招聘系统-首页</title>
<link rel="short icon" href="images/copylogo.png">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/foot.css">
</head>
<body>
<div id="positions_info">
	<!-- 头部  -->
	<div class="header_con">
	 	<div class="header">
	 		<div class="welcome fl">欢迎来到兼职招聘系统-17级软2邓强</div>
	 		<div class="fr">
	         	<div id="n" class="login_info fl"> 欢迎：<p id="em"  style="margin-right: 15px; color:blue">d q</p>
	             </div>
	             <div class="login_btn fl" >
	             	<a href="login.html" id="login">登录</a>
	             	<input type="button" class="dqbtn" id="loginout" value="退出登录" style="display:none" onclick="loginout()">
	                 <span> | </span>
	                 <a href="register_jober.html">注册</a>
	             </div>
	         	 <div class="user_link fl">
	                 <span> | </span>
	                 <a href="front/user_jober.html">用户中心</a>
	                 <span> | </span>
	                 <a href="front/resume.html">我的简历</a>
	                 <span> | </span>
	                 <a href="front/delivery.html">我的投递</a>
	        		 </div> 
	          </div>  
	 	</div>
	 </div>

    
     <!-- 搜素框 -->
     <div class="search_bar clearfix">
     		<a href="login.html" target="_blank"  class="logo fl"><img src="images/logo.png"></a>
     		<div class="search_con fl">
            	<form>
                    <input type="text" id="search" class="input_text fl" name="key_words" placeholder="输入职位名或企业名" autocomplete="off">
                    <input type="button" class="input_btn fr"  value="搜索" @click="search" >
                </form>
            </div>
     		<div class="guest_cart fr" >
            	<a href="front/favorites.html" class="cart_name fl">我的收藏</a>
                <div class="goods_count fl" id="show_count">{{favorites}}</div>
            </div>
            <div id="dqtis" style="margin-top: 89px;margin-left: 300px;color: red;"></div>
     </div>

    <!-- 职位分类 -->
    <div class="navbar_con">
    	<div class="navbar">
    		<h1 class="fl">全职位分类</h1>
    		<ul class="navlist fl">
    			<li><a href="">首页</a></li>
                <li class="interval">|</li>
                <li><a href="">手机招聘</a></li>
                <li class="interval">|</li>
                <li><a href="">抽奖</a></li>
    		</ul>
    	</div>
    </div>
    
    <!-- 导航栏 -->
    <div class="center_con clearfix">
        <div class="subnav fl">
            <ul>
                <li><a href="#model01" class="fruit">技术</a></li>
                <li><a href="#model02" class="seafood">产品</a></li>
                <li><a href="#model03" class="meet">设计</a></li>
                <li><a href="#model04" class="ice">人事</a></li>
                <li><a href="#model" class="egg">校园兼职</a></li>
                <li><a href="#model" class="vegetables">市场</a></li>           
            </ul>
        </div>
        <div class="slide fl">
            <ul class="slide_pics">
                <li><a href="" class=""><img src="images/slide.jpg" alt="幻灯片"></a></li>
                <li><a href="" class=""><img src="images/slide02.jpg" alt="幻灯片"></a></li>
                <li><a href="" class=""><img src="images/slide03.jpg" alt="幻灯片"></a></li>
                <li><a href="" class=""><img src="images/slide04.jpg" alt="幻灯片"></a></li>
            </ul>
            <div class="prev"></div>
            <div class="next"></div>
            <ul class="points"></ul>
        </div>
        <div class="adv fl">
            <a href=""><img src="images/adv01.jpg" alt="最高年薪"></a>
            <a href=""><img src="images/adv02.jpg" alt="我才是设计师"></a>
        </div>
    </div>

    <!-- 职位展示 -->
    <div class="list_model"  v-for="type in types">
    	<div class="list_title clearfix">
        	<h3 class="fl" id="model01">{{type.tname}}</h3>
        	<div class="subtitle fl">
            	<span>|</span>
                <a :href="'details.html#' + pd.pno" target="_blank" v-for="pd in positions" v-if="pd.tno==type.tno">{{pd.pname}}</a>
            </div>
            <a href="positions.html" target="_blank" class="goods_more fr" id="fruit_more">查看更多</a>
        </div>
    
    	<div class="goods_con clearfix">
        	<div class="goods_banner fl"><img :src="type.pic"></div>
        	<ul class="goods_list fl" id="fruit_list">
				<li v-for="pd in positions" v-if="pd.tno == type.tno">
                	<h4><a :href="'details.html#' + pd.pno" target="_blank">{{pd.pname}}</a></h4>
                    <a :href="'details.html#' + pd.pno" target="_blank"><img :src="pd.companypic"></a>
                	<div class="prize">月薪： {{pd.price}}</div>
                </li>
        	</ul>
        </div>
    </div>
</div>	
 
    <!-- 版权所有 -->
    <div class="footer">
    	<div class="foot_link">
        	<a href="#">关于我们</a> <span> | </span>
            <a href="#">联系我们</a> <span> | </span>
            <a href="#">招聘广告</a> <span> | </span>
            <a href="#">友情链接</a>
        </div>
    	<p>CopyRight &copy; 2021 衡阳市南华大学船山学院17级软件2班邓强 All Rights Reserverd</p>
        <p>电话：1787-3443012 </p>
    </div>
    
    <!--  注意引入顺序 -->
	<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui.min.js"></script>
    <script type="text/javascript" src="js/slide.js"></script>
    <script type="text/javascript" src="js/qs.js"></script>
    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript" src="js/axios.js"></script> 
    <script src="js/websocket.js"></script>
    
    <script type="text/javascript">
		$(function(){
			//检查登录
			joberCheck();
		})
		
		let positions_info = new Vue({
			el:"#positions_info",
			data:{
				positions:{},
				types:{},
				nickname:"",
				pname:"",
				favorites:0
			},
			methods:{
				search : function(){
					var pname = $.trim($("#search").val());
					if(pname == ""){
						$("#dqtis").text("请输入关键词...");
						return;
					}else{
						$("#dqtis").text("");
						console.log("查找:"+pname);
						window.open("positions_search.html#"+pname);
					}
				}
			},
			mounted:function(){

				axios.post("login/getnickname", {params:{}}).then(result =>{
					this.nickname = result.data.nickName;
					
					//查询收藏信息
					axios.get("favorites/findAll", {params:{nickname:this.nickname}}).then(result =>{
						this.favorites = Object.keys(result.data.positions).length;
						console.log("共："+this.favorites +"条收藏信息");
					})	
				})
								
				//查询首页信息
				axios.get("positions/index", {params:{}}).then(result =>{
					this.types=result.data.types;
					this.positions=result.data.positions;
				})

			}
		})
		
		//获取用户名
		function getnickname(){
			$.post("login/getnickname", {}, function(data) {
				//用户昵称
				console.log("当前登录的用户名为：" + data.nickName);
				$("#em").text(data.nickName);
				$("#n").css('display', 'flex');
				$("#loginout").css('display', 'inline');
				$("#login").css('display', 'none');
			}, "json");
		}
		
		//下线
		function loginout(){
			$.post("login/loginout", {}, function(data) {
				console.log("下线了...");
			}, "text");
			window.location.reload();
		}
		
		function joberCheck(){
				//先发送请求获取登录用户id
				$.get("login/joberCheck", null, function(data){
				if (data.code == 500) {
					console.log("请先登录...");
					$("#em").text("你好！请先登录...");
					$("#n").css('display', 'flex');
					return;
				}
			
				if (data.code == 200) {
					//连上 websocket服务器
					openWebSocket(data.msg);
					getnickname();
				}
			},"json");
		}
    
/* 		$(function(){
			//先发送请求获取登录用户id
			$.get("login/joberCheck", null, function(data){
			if (data.code == 500) {
				alert("请先登录...");
				location.href="../login.html";
				return;
			}
		
			if (data.code == 200) {
				//连上 websocket服务器
				openWebSocket(data.msg);
			}
		},"json");
	}) */
		
    </script>
</body>
</html>
